#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt
from inary.actionsapi import inarytools
from inary.actionsapi import autotools as tools
from inary.actionsapi import get
#more information : https://gitlab.com/sulinos/inary/tree/master/inary/actionsapi

import os

def build():
    tools.make()

def install():
    inarytools.insinto("/bin", "busybox")
    inarytools.insinto("/etc","examples/udhcp/udhcpd.conf")
    inarytools.insinto("/usr/share/udhcpc","default.script")
    inarytools.dodir("/etc/alternative/init")
    inarytools.dosym("/bin/busybox","/etc/alternative/init/busybox")
    os.system("""
    for i in $(busybox --list)
    do
        if which $i &>/dev/null ; then
                true
        else
                ln -s ../bin/busybox {0}/usr/bin/$i
        fi
    done
    for applet in su login
    do
        chmod u+s {0}/usr/bin/$applet
    done
    """.format(get.installDIR()))
